﻿using System;
using System.Collections.Generic;
using System.Linq;
using Informant.Contacts;
using Informant.SmsMessaging;

namespace Informant.Clients.DataProviders.Wpf4.InformantService
{

	public partial class Sms : ISms
	{
		public IEnumerable<IMessage> Messages
		{
			get { return ServiceModelMessages.OfType<IMessage>(); }
			set
			{
				var messages = value.OfType<Message>().ToList();
				if (ServiceModelMessages != messages)
				{
					ServiceModelMessages = messages;
					RaisePropertyChanged("Messages");
				}
			}
		}

		public IEnumerable<IPhone> Recipients
		{
			get { return ServiceModelRecipients.OfType<IPhone>(); }
			set
			{
				var recipients = value.OfType<Phone>().ToList();
				if (ServiceModelRecipients != recipients)
				{
					ServiceModelRecipients = recipients;
					RaisePropertyChanged("Recipients");
				}
			}
		}

		public IPhone Sender
		{
			get { return ServiceModelSender; }
			set
			{
				var sender = value as Phone;
				if (sender != null && ServiceModelSender != sender)
				{
					ServiceModelSender = sender;
					RaisePropertyChanged("Sender");
				}
			}
		}
	}
}
